<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>日期框之日期格式 - jQuery EasyUI 演示</title>
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../demo.css">
	<script type="text/javascript" src="../../jquery.min.js"></script>
	<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../locale/easyui-lang-zh_CN.js"></script>
</head>
<body>
	<h2 title="Date Format">日期框之日期格式</h2>
	<p title="Different date formats are applied to different DateBox components.">　　各种各样的日期格式可提供给不同的日期框组件（如下，分别为：YYYY-MM-DD 和 M.D.YYYY）。</p>
	<div class="easyui-panel" style="width:100%;max-width:250px;padding:10px 20px;">
		<div style="margin-bottom:10px">
			<input class="easyui-datebox" label="<h title='Default Format:'>默认格式：</h>" labelPosition="left" labelWidth="100" labelAlign="right" style="width:100%;">
		</div>
		<div style="margin-bottom:0px">
			<input class="easyui-datebox" label="<h title='Customized Format:'>自定格式：</h>" labelPosition="left" labelWidth="100" labelAlign="right" data-options="formatter:myformatter,parser:myparser" style="width:100%;">
		</div>
	</div>
	<script type="text/javascript">
		function myformatter(date){
			var y = date.getFullYear();
			var m = date.getMonth()+1;
			var d = date.getDate();
			return m+'.'+d+'.'+y;
			//return (m<10?('0'+m):m)+'.'+(d<10?('0'+d):d)+'.'+y;
		}
		function myparser(s){
			if (!s) return new Date();
			var ss = (s.split('.'));
			var y = parseInt(ss[2],10);
			var m = parseInt(ss[0],10);
			var d = parseInt(ss[1],10);
			if (!isNaN(y) && !isNaN(m) && !isNaN(d)){return new Date(y,m-1,d);} else{return new Date();}
		}
	</script>
</body>
</html>